#include "bflb_mtimer.h"
#include "bflb_i2c.h"
#include "board.h"
#include "INA226.h"
#include "bflb_gpio.h"

struct bflb_device_s *i2c0;

int main(void)
{
    struct bflb_device_s* gpio;
    board_init();

    gpio = bflb_device_get_by_name("gpio");
    /* I2C0_SCL */
    bflb_gpio_init(gpio, GPIO_PIN_0, GPIO_FUNC_I2C0 | GPIO_ALTERNATE | GPIO_PULLUP | GPIO_SMT_EN | GPIO_DRV_1);
    /* I2C0_SDA */
    bflb_gpio_init(gpio, GPIO_PIN_1, GPIO_FUNC_I2C0 | GPIO_ALTERNATE | GPIO_PULLUP | GPIO_SMT_EN | GPIO_DRV_1);
    i2c0 = bflb_device_get_by_name("i2c0");

    bflb_i2c_init(i2c0, 400000);
    bflb_mtimer_delay_ms(1000);
    INA226_Init();

    while(1){
        bflb_mtimer_delay_ms(1000);
        INA226_TEST();
    }
}
